import Vue from 'vue'
import Router from 'vue-router'

import layout from "../views/layout/layout";
import login from "../views/index/login";
import home from "../views/index/home";
import error from "../views/index/error";

const screen = ()=>import("../views/index/screen")
const toolMap = ()=>import("../views/tools/toolMap")
const magnifying = ()=>import("../views/tools/magnifying");
//店铺设置
const shopManagement = ()=>import("../views/shopManagement/shopManagement")

const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}
Vue.use(Router);

/*
* hidden:渲染菜单是隐藏
* alone：是否是一级菜单
* */
let defaultRouter = [
  {path: "/", redirect: "/index", hidden: true},
  // 登录
  {path: "/login", name: "login",component: login, hidden: true},
  {
    path: "/index",
    iconCls: "fa fa-line-chart", // 图标样式class
    name: "数据中心",
    component: layout,
    alone: true,
    children: [
      {
        path: "/index",
        iconCls: "fa fa-area-chart",
        name: "数据中心",
        component: home,
        children: []
      }
    ]
  }
];

let addRouter = [
  {
    path: "/layout",
    iconCls: "fa fa-line-chart", // 图标样式class
    name: "系统管理",
    component: layout,
    children: [
      {
        path: "/shopManagement",
        iconCls: "fa fa-area-chart",
        name: "店铺设置",
        component: shopManagement,
        children: []
      },
    ]
  },
  {
    path: "/layout",
    iconCls: "fa fa-line-chart", // 图标样式class
    name: "工具栏",
    component: layout,
    children: [
      {
        path: "/map",
        iconCls: "fa fa-area-chart",
        name: "高德地图",
        component: toolMap,
        children: []
      },
      {
        path: "/magnifying",
        iconCls: "fa fa-area-chart",
        name: "图片放大镜",
        component: magnifying,
        children: []
      }
    ]
  },
  {
    path: "/layout",
    component: layout,
    children: [
      {
        path: "/screen",
        component: screen,
        children: []
      },
      {
        path: "/error",
        component: error,
        children: []
      }
    ]
  },
  {
    path: "/layout",
    component: layout,
    children: [
      {
        path: "/screen",
        component: screen,
        children: []
      },
      {
        path: "/error",
        component: error,
        children: []
      }
    ]
  },
];

const router = new Router({
  routes: defaultRouter.concat(addRouter)
});

export default router;
export {defaultRouter, addRouter};


